package com.design.controller.app;


import com.design.model.BaseResult;
import com.design.model.UserInfoResponse;
import com.design.model.UserInfoUpdateRequest;
import com.design.service.ManageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@Api(tags = "【APP端-用户管理】")
@RequestMapping("/user")
@CrossOrigin(origins = "*")
public class UserController {

    @Autowired
    private ManageService manageService;

    /**
     * 查询用户详情
     *
     * @param id 帐号
     * @return 用户详情
     */
    @ApiOperation(value = "用户管理-查询用户详情")
    @GetMapping("/queryById")
    public BaseResult<UserInfoResponse> queryById(Long id) {
        return new BaseResult<>(manageService.queryById(id));
    }

    /**
     * 修改密码
     *
     * @param request 密码
     * @return 修改结果
     */
    @ApiOperation(value = "用户管理-修改密码")
    @PostMapping("/updatePassword")
    public BaseResult<Void> updatePassword(@RequestBody UserInfoUpdateRequest request) {
        manageService.updatePassword(request);
        return new BaseResult<>();
    }

    /**
     * 修改手机
     *
     * @param request 手机
     * @return 修改结果
     */
    @ApiOperation(value = "用户管理-修改手机")
    @PostMapping("/updatePhone")
    public BaseResult<Void> updatePhone(@RequestBody UserInfoUpdateRequest request) {
        manageService.updatePhone(request);
        return new BaseResult<>();
    }


}
